<?php
// +----------------------------------------------------------------------
// | OneThink [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.onethink.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: 麦当苗儿 <zuojiazi@vip.qq.com> <http://www.zjzit.cn>
// +----------------------------------------------------------------------

namespace Home\Controller;
use OT\DataDictionary;

/**
 * 前台首页控制器
 * 主要获取首页聚合数据
 */
class IndexController extends HomeController {

	//系统首页
    public function index(){

//        $category = D('Category')->getTree();
//        $lists    = D('Document')->lists(null);
//
//        $this->assign('category',$category);//栏目
//        $this->assign('lists',$lists);//列表
//        $this->assign('page',D('Document')->page);//分页
        $model = M("News");
        $data = $model->order('id desc')->limit(7)->select();
//        echo "<pre>".print_r($data,true)."</pre>";
        $this->assign("data",$data[0]);
        array_shift($data);
        $this->assign("list",$data);

        //查询首页校园风采的图片
        $img_model = M("Img");
        $img_data = $img_model->order('id desc')->limit(10)->select();

        foreach($img_data as $key => &$value){
            $info = pathinfo($value['path']);

            $value['path'] = '/upload/'.$info['filename'].'_min.'.$info['extension'];
//            echo "<pre>".print_r($value['path'],true)."</pre>";
        }

        $this->assign("img_data",$img_data);

        $this->display();
    }

    //关于我们
    public function about(){
        $this->display();
    }
    //新闻列表
    public function nlist(){
        $model = M("News");
        $data = $model->order('id desc')->limit(9)->select();
//        echo "<pre>".print_r($data,true)."</pre>";
        $this->assign("list",$data);

        $this->display();
    }

    //产品列表
    public function plist(){
        $this->display();
    }

    //集装箱租赁列表
    public function rlist(){
        $this->display();
    }

    //科普知识列表
    public function ilist(){
        $this->display();
    }

    //优势页面
    public function virtue(){
        $this->display();
    }

//    public function detail(){
//
//
//        $id = I("id",0);
//
//        if(!$id){
//            header("location:".getenv("HTTP_REFERER"));
//            die;
//        }
//        $model  = M("News");
//        $data = $model->where(array('id'=>$id))->find();
//
//        $this->assign("data",$data);
//        $this->display();
//    }

//    public function jianjie(){
//
//
//        $this->display();
//    }

//    public function connect(){
//        $this->display();
//    }


//    public function fengcai(){
//
//        //查询分类
//        $classify_model  = M("Classify");
//        $classify_data = $classify_model->select();
//
//        $this->assign("classify_data",$classify_data);
//
//        //默认查询所有分类的内容
//        $img_model = M("Img");
//        $img_data = $img_model->order('id desc')->limit(9)->select();
//        $this->assign("img_data",$img_data);
//
//
//        $this->display();
//    }

}